<template>
    <Form v-model="fromItem" :label-width="120">
        <Row>
            <Card>
                <p slot="title">
                    <Icon type="ios-flower"></Icon>
                    编辑推荐施肥方案
                </p>
                <Row style="margin: 20px">
                    <i-col span="22">
                        <label>土壤养分名称：</label>
                        <!--<Select v-model="nutrchose" style="width:200px">-->
                            <!--<Option v-for="item in fromItem.nutrList" :value="item" :key="item">-->
                                <!--{{ item }}-->
                            <!--</Option>-->
                        <!--</Select>-->
                    </i-col>
                </Row>
                <Row style="margin: 20px">
                    <i-col span="22">
                        <label>土壤测试指标：</label>
                        <!--<Select v-model="elementchose" style="width:200px">-->
                            <!--<Option v-for="item in fromItem.elementList" :value="item" :key="item">-->
                                <!--{{ item }}-->
                            <!--</Option>-->
                        <!--</Select>-->
                    </i-col>
                </Row>
                <Row align="middle" style="width:400px" class="height-100">
                    <!--<Table :border="true" :columns="table_titles" :data="fromItem.tableDatas"></Table>-->
                </Row>

                <Row style="margin: 20px;align:right">
                    <Form-item>
                        <i-button type="primary" @click="commit">提交</i-button>
                        <i-button type="ghost" @click="cancle" style="margin-left: 8px">取消</i-button>
                    </Form-item>
                </Row>
            </Card>
        </Row>
    </Form>
</template>
<style>
    body {
        background-color: #ff0000;
    }
    .show-edit-btn {
        margin-left: -10px;
    }
</style>
<script>
    export default {
        data() {
            return {
                fromItem: {
                    nutrList: [],
                    elementList: [],
                    tableDatas: []
                },
                nutrchose: "请选择",
                elementchose: "请选择",
                table_titles: [
                    {
                        title: '测试值',
                        align: 'center',
                        key: 'value',
                        render: (h, params) => {
//                            console.log("测试:", params.row.value)
                            return h('Input', {
                                props: {
                                    value: params.row.value,
                                },
                                style: {
                                    width: '100px'
                                }
                            })
                        }
                    },
                    {
                        title: '推荐量（公斤）',
                        key: 'dosage',
                        align: 'center',
                        render: (h, params) => {
//                            console.log("推荐：", params.row.dosage)
                            return h('Input', {
                                props: {
                                    value: params.row.dosage,
                                },
                                style: {
                                    width: '100px',
                                    textAlign: 'center',
                                }
                            })
                        }
                    },
                ],
            }
        },
        created() {
//            console.log("fromItem", this.$route.params.datas)
            this.fromItem = this.$route.params.datas;
            if (this.fromItem) {
                this.nutrchose = this.fromItem.nutrList[0];
                this.elementchose = this.fromItem.elementList[0];
            }
        },
        methods: {
            commit: function () {
                const title = '提交成功';
                const content = "提交成功!"
                this.$Modal.info({
                    title: title,
                    content: content,
                })
                this.$router.replace({name: "recom_fert"});
            },
            cancle: function () {
                this.$router.replace({name: "recom_fert"});
            }
        },
    }
</script>